<?
    my $message_count = $EQW->CountConsoleMessages();
    print "{";
    print "\"message_count\" : $message_count,";
    print "\"messages\" : ";
    print "[";
    for(my $i = 0; $i < $message_count; $i++)
    {
        print "{";
        my $msg = $EQW->GetConsoleMessage($i);
        $message = $msg->{message};
        $message =~ s/\\/\\\\/g;
        $message =~ s/\//\\\//g;
        $message =~ s/\"/\\\"/g;
        $message =~ s/\n/\\n/g;
        $message =~ s/\r/\\r/g;
        $message =~ s/\t/\\t/g;
        $message =~ s/\x08/\\f/g;
        $message =~ s/\x0C/\\b/g;
        $message =~ s/[\x00-\x1F]/\./g;
        $message =~ s/[\x7F-\xFF]/\./g;

        print "\"message\" : \"$message\"";
        print "}";
        if($i != $message_count - 1) {
            print ",";
        }
    }
    print "]";
    print "}";
?>